<?php
class MyEmailComponent extends Object
{
    public $components = array('Email');
    public $controller;

    public $to = "";
    public $subject = "";
    public $template = "default";
    public $sendAs = "html";
    public $from = "";
    public $data = null;


    public function startup(&$controller)
    {
        $this->controller = $controller;
    }

    public function send()
    {
        $this->Email->to = $this->to;
        $this->Email->subject = $this->subject;
        $this->Email->from = $this->from;
        $this->Email->template = $this->template; // note no '.ctp'

        //Send as 'html', 'text' or 'both' (default is 'text')
        $this->Email->sendAs = $this->sendAs; // because we like to send pretty mail

        //Set view variables as normal
        $this->controller->set('data', $this->data);

        //Do not pass any args to send()
        return $this->Email->send();
    }
}
?>